import {Modal} from 'antd';
import {WeaSearchGroup, WeaDropdown,WeaTag, WeaFormItem} from 'ecCom';
import {WeaSwitch} from 'comsMobx';
import {WeaLocaleProvider} from 'ecCom';
const getLabel = WeaLocaleProvider.getLabel;

//用于获取高级搜索中的表单控件
let formParams = {};
export const getStrongSearchs = (form, datas, needTigger = true, col=1,onEnterSearch) => {
  const {isFormInit} = form;
  let group = [];

  const formParamsTemp = form.getFormParams();
  for (let i in formParamsTemp){
    formParams[i] = formParamsTemp[i];
  }
  isFormInit && datas && datas.map((c,i) =>{
    let items = [];
    c.items.map(fields => {
        if (onEnterSearch && typeof onEnterSearch === 'function' && fields.conditionType === 'INPUT') {
            fields.onPressEnter = onEnterSearch;
        }
      items.push({
        com:(<WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@3s6hdd@${fields.domkey[0]}`}
          label={`${fields.label}`}
          labelCol={{span: 6}}
          wrapperCol={{span: 14}}>
          <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@kk89l3@${fields.domkey[0]}`} fieldConfig={fields} form={form} formParams={formParams}/>
        </WeaFormItem>),
        colSpan:1
      })
    });
    if(needTigger){
      group.push(<WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@dmd45s@${i}`} col={col} needTigger={needTigger} title={c.title} showGroup={c.defaultshow} items={items}/>)
    }else {
      group.push(<WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@jqi3lz@${i}`} col={col} needTigger={needTigger} showGroup={c.defaultshow} items={items}/>)
    }
  });
  return group;
}